<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickframebufferobject.cpp -->
  <title>QQuickFramebufferObject 类 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-module.html">C++ 类</a></td><td >QQuickFramebufferObject</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#public-types">公用类型</a></li>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#public-functions">公用函数</a></li>
<li class="level1"><a href="#reimplemented-public-functions">重新实现的公用函数</a></li>
<li class="level1"><a href="#signals">信号</a></li>
<li class="level1"><a href="#static-public-members">静态公用成员</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QQuickFramebufferObject 类</h1>
<!-- $$$QQuickFramebufferObject-brief -->
<p>The <a href="qquickframebufferobject.html">QQuickFramebufferObject</a> class is a convenience class for integrating OpenGL rendering using a framebuffer object (FBO) with Qt Quick. <a href="#details">更多...</a></p>
<!-- @@@QQuickFramebufferObject -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign">头文件：</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QQuickFramebufferObject&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += quick</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.2</td></tr><tr><td class="memItemLeft rightAlign topAlign">继承自：</td><td class="memItemRight bottomAlign"> <a href="qquickitem.html">QQuickItem</a></td></tr></table></div><ul>
<li><a href="qquickframebufferobject-members.html">所有成员的列表，包括继承成员</a></li>
<li><a href="qquickframebufferobject-obsolete.html">废弃的成员</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">公用类型</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject-renderer.html">Renderer</a></b></td></tr>
</table></div>
<ul>
<li class="fn">1 public type inherited from <a href="qquickitem.html#public-types">QQuickItem</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><a href="qquickframebufferobject.html#mirrorVertically-prop">mirrorVertically</a></b> : bool</li>
<li class="fn"><b><a href="qquickframebufferobject.html#textureFollowsItemSize-prop">textureFollowsItemSize</a></b> : bool</li>
</ul>
<ul>
<li class="fn">24 个属性继承自<a href="qquickitem.html#properties">QQuickItem</a></li>
<li class="fn">1 个属性继承自<a href="../qtcore/qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">公用函数</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#QQuickFramebufferObject">QQuickFramebufferObject</a></b>(QQuickItem *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QQuickFramebufferObject::Renderer *</td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#createRenderer">createRenderer</a></b>() const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#mirrorVertically-prop">mirrorVertically</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#mirrorVertically-prop">setMirrorVertically</a></b>(bool <i>enable</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#textureFollowsItemSize-prop">setTextureFollowsItemSize</a></b>(bool <i>follows</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#textureFollowsItemSize-prop">textureFollowsItemSize</a></b>() const</td></tr>
</table></div>
<a name="reimplemented-public-functions"></a>
<h2 id="reimplemented-public-functions">重新实现的公用函数</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#isTextureProvider">isTextureProvider</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#releaseResources">releaseResources</a></b>() override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QSGTextureProvider *</td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#textureProvider">textureProvider</a></b>() const override</td></tr>
</table></div>
<ul>
<li class="fn">101 个公用函数继承自<a href="qquickitem.html#public-functions">QQuickItem</a></li>
<li class="fn">31 个公用函数继承自<a href="../qtcore/qobject.html#public-functions">QObject</a></li>
<li class="fn">2 个公用函数继承自<a href="../qtqml/qqmlparserstatus.html#public-functions">QQmlParserStatus</a></li>
</ul>
<a name="signals"></a>
<h2 id="signals">信号</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#mirrorVertically-prop">mirrorVerticallyChanged</a></b>(<i>bool</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#textureFollowsItemSize-prop">textureFollowsItemSizeChanged</a></b>(<i>bool</i>)</td></tr>
</table></div>
<ul>
<li class="fn">2 个信号继承自<a href="qquickitem.html#signals">QQuickItem</a></li>
<li class="fn">2 个信号继承自<a href="../qtcore/qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2 id="static-public-members">静态公用成员</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qquickframebufferobject.html#staticMetaObject-var">staticMetaObject</a></b></td></tr>
</table></div>
<ul>
<li class="fn">9 个静态公用成员继承自<a href="../qtcore/qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>额外的继承成员</h3>
<ul>
<li class="fn">1 个公用槽函数继承自<a href="qquickitem.html#public-slots">QQuickItem</a></li>
<li class="fn">1 个公用槽函数继承自<a href="../qtcore/qobject.html#public-slots">QObject</a></li>
<li class="fn">33 个保护函数继承自<a href="qquickitem.html#protected-functions">QQuickItem</a></li>
<li class="fn">9 个保护函数继承自<a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QQuickFramebufferObject-description -->
<div class="descr">
<h2 id="details">详细信息</h2>
<p>The <a href="qquickframebufferobject.html">QQuickFramebufferObject</a> class is a convenience class for integrating OpenGL rendering using a framebuffer object (FBO) with Qt Quick.</p>
<p>On most platforms, the rendering will occur on a <a href="qtquick-visualcanvas-scenegraph.html#scene-graph-and-rendering">dedicated thread</a>. For this reason, the <a href="qquickframebufferobject.html">QQuickFramebufferObject</a> class enforces a strict separation between the item implementation and the FBO rendering. All item logic, such as properties and UI-related helper functions needed by QML should be located in a <a href="qquickframebufferobject.html">QQuickFramebufferObject</a> class subclass. Everything that relates to rendering must be located in the <a href="qquickframebufferobject-renderer.html">QQuickFramebufferObject::Renderer</a> class.</p>
<p>To avoid race conditions and read/write issues from two threads it is important that the renderer and the item never read or write shared variables. Communication between the item and the renderer should primarily happen via the <a href="qquickframebufferobject-renderer.html#synchronize">QQuickFramebufferObject::Renderer::synchronize</a>() function. This function will be called on the render thread while the GUI thread is blocked.</p>
<p>Using queued connections or events for communication between item and renderer is also possible.</p>
<p>Both the Renderer and the FBO are memory managed internally.</p>
<p>To render into the FBO, the user should subclass the Renderer class and reimplement its <a href="qquickframebufferobject-renderer.html#render">Renderer::render</a>() function. The Renderer subclass is returned from <a href="qquickframebufferobject.html#createRenderer">createRenderer</a>().</p>
<p>The size of the FBO will by default adapt to the size of the item. If a fixed size is preferred, set <a href="qquickframebufferobject.html#textureFollowsItemSize-prop">textureFollowsItemSize</a> to <code>false</code> and return a texture of your choosing from <a href="qquickframebufferobject-renderer.html#createFramebufferObject">QQuickFramebufferObject::Renderer::createFramebufferObject</a>().</p>
<p>Starting Qt 5.4, the <a href="qquickframebufferobject.html">QQuickFramebufferObject</a> class is a <a href="qsgtextureprovider.html">texture provider</a> and can be used directly in <a href="qml-qtquick-shadereffect.html">ShaderEffects</a> and other classes that consume texture providers.</p>
</div>
<p><b>请参考 </b><a href="qtquick-scenegraph-textureinsgnode-example.html">Scene Graph - Rendering FBOs</a> 和 <a href="qtquick-visualcanvas-scenegraph.html#scene-graph-and-rendering">Scene Graph 和 Rendering</a>。</p>
<!-- @@@QQuickFramebufferObject -->
<div class="prop">
<h2>属性文档</h2>
<!-- $$$mirrorVertically-prop$$$mirrorVertically$$$setMirrorVerticallybool$$$mirrorVerticallyChangedbool -->
<h3 class="fn" id="mirrorVertically-prop"><a name="mirrorVertically-prop"></a><span class="name">mirrorVertically</span> : <span class="type">bool</span></h3>
<p>This property controls if the size of the FBO's contents should be mirrored vertically when drawing. This allows easy integration of third-party rendering code that does not follow the standard expectations.</p>
<p>The default value is <code>false</code>.</p>
<p>This property was introduced in  Qt 5.6.</p>
<p><b>访问函数：</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>mirrorVertically</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setMirrorVertically</b></span>(bool <i>enable</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>mirrorVerticallyChanged</b></span>(<i>bool</i>)</td></tr>
</table></div>
<!-- @@@mirrorVertically -->
<!-- $$$textureFollowsItemSize-prop$$$textureFollowsItemSize$$$setTextureFollowsItemSizebool$$$textureFollowsItemSizeChangedbool -->
<h3 class="fn" id="textureFollowsItemSize-prop"><a name="textureFollowsItemSize-prop"></a><span class="name">textureFollowsItemSize</span> : <span class="type">bool</span></h3>
<p>This property controls if the size of the FBO's texture should follow the dimensions of the <a href="qquickframebufferobject.html">QQuickFramebufferObject</a> item. When this property is false, the FBO will be created once the first time it is displayed. If it is set to true, the FBO will be recreated every time the dimensions of the item change.</p>
<p>The default value is <code>true</code>.</p>
<p><b>访问函数：</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>textureFollowsItemSize</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTextureFollowsItemSize</b></span>(bool <i>follows</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>textureFollowsItemSizeChanged</b></span>(<i>bool</i>)</td></tr>
</table></div>
<!-- @@@textureFollowsItemSize -->
</div>
<div class="func">
<h2>成员函数文档</h2>
<!-- $$$QQuickFramebufferObject[overload1]$$$QQuickFramebufferObjectQQuickItem* -->
<h3 class="fn" id="QQuickFramebufferObject"><a name="QQuickFramebufferObject"></a>QQuickFramebufferObject::<span class="name">QQuickFramebufferObject</span>(<span class="type"><a href="qquickitem.html#QQuickItem">QQuickItem</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a new <a href="qquickframebufferobject.html">QQuickFramebufferObject</a> with parent <i>parent</i>.</p>
<!-- @@@QQuickFramebufferObject -->
<!-- $$$createRenderer[overload1]$$$createRenderer -->
<h3 class="fn" id="createRenderer"><a name="createRenderer"></a><code>[pure virtual] </code><span class="type"><a href="qquickframebufferobject-renderer.html">QQuickFramebufferObject::Renderer</a></span> *QQuickFramebufferObject::<span class="name">createRenderer</span>() const</h3>
<p>Reimplement this function to create a renderer used to render into the FBO.</p>
<p>This function will be called on the rendering thread while the GUI thread is blocked.</p>
<!-- @@@createRenderer -->
<!-- $$$isTextureProvider[overload1]$$$isTextureProvider -->
<h3 class="fn" id="isTextureProvider"><a name="isTextureProvider"></a><code>[override virtual] </code><span class="type">bool</span> QQuickFramebufferObject::<span class="name">isTextureProvider</span>() const</h3>
<p>重新实现自<a href="qquickitem.html#isTextureProvider">QQuickItem::isTextureProvider</a>()。</p>
<!-- @@@isTextureProvider -->
<!-- $$$releaseResources[overload1]$$$releaseResources -->
<h3 class="fn" id="releaseResources"><a name="releaseResources"></a><code>[override virtual] </code><span class="type">void</span> QQuickFramebufferObject::<span class="name">releaseResources</span>()</h3>
<p>重新实现自<a href="qquickitem.html#releaseResources">QQuickItem::releaseResources</a>()。</p>
<!-- @@@releaseResources -->
<!-- $$$textureProvider[overload1]$$$textureProvider -->
<h3 class="fn" id="textureProvider"><a name="textureProvider"></a><code>[override virtual] </code><span class="type"><a href="qsgtextureprovider.html">QSGTextureProvider</a></span> *QQuickFramebufferObject::<span class="name">textureProvider</span>() const</h3>
<p>重新实现自<a href="qquickitem.html#textureProvider">QQuickItem::textureProvider</a>()。</p>
<!-- @@@textureProvider -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
